package com.db.client;

import com.db.transport.client.listener.SessionClientListener;

import java.io.PrintWriter;

/**
 * @author nulls.narik
 */
public class ClientListener implements SessionClientListener {

    private final PrintWriter writer;

    private final long startTime;

    public ClientListener(PrintWriter writer) {
        startTime = System.currentTimeMillis();
        this.writer = writer;
    }

    @Override
    public void newMessage(String message) {
        writer.println(String.format("time: [%d]. message: \"%s\"", System.currentTimeMillis() - startTime, message));
    }
}
